package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.FloPopBg;
import com.ruoyi.system.service.IFloPopBgService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 流动人口变更Controller
 * 
 * @author ruoyi
 * @date 2024-10-15
 */
@Controller
@RequestMapping("/system/ld_bg")
public class FloPopBgController extends BaseController
{
    private String prefix = "system/ld_bg";

    @Autowired
    private IFloPopBgService floPopBgService;

    @RequiresPermissions("system:ld_bg:view")
    @GetMapping()
    public String ld_bg()
    {
        return prefix + "/ld_bg";
    }

    /**
     * 查询流动人口变更列表
     */
    @RequiresPermissions("system:ld_bg:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(FloPopBg floPopBg)
    {
        startPage();
        List<FloPopBg> list = floPopBgService.selectFloPopBgList(floPopBg);
        return getDataTable(list);
    }

    /**
     * 导出流动人口变更列表
     */
    @RequiresPermissions("system:ld_bg:export")
    @Log(title = "流动人口变更", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(FloPopBg floPopBg)
    {
        List<FloPopBg> list = floPopBgService.selectFloPopBgList(floPopBg);
        ExcelUtil<FloPopBg> util = new ExcelUtil<FloPopBg>(FloPopBg.class);
        return util.exportExcel(list, "流动人口变更数据");
    }

    /**
     * 新增流动人口变更
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存流动人口变更
     */
    @RequiresPermissions("system:ld_bg:add")
    @Log(title = "流动人口变更", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(FloPopBg floPopBg)
    {
        return toAjax(floPopBgService.insertFloPopBg(floPopBg));
    }

    /**
     * 修改流动人口变更
     */
    @RequiresPermissions("system:ld_bg:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        FloPopBg floPopBg = floPopBgService.selectFloPopBgById(id);
        mmap.put("floPopBg", floPopBg);
        return prefix + "/edit";
    }

    /**
     * 修改保存流动人口变更
     */
    @RequiresPermissions("system:ld_bg:edit")
    @Log(title = "流动人口变更", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(FloPopBg floPopBg)
    {
        return toAjax(floPopBgService.updateFloPopBg(floPopBg));
    }

    /**
     * 删除流动人口变更
     */
    @RequiresPermissions("system:ld_bg:remove")
    @Log(title = "流动人口变更", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(floPopBgService.deleteFloPopBgByIds(ids));
    }
}
